<?php
namespace app\admin\controller;
use app\admin\controller\Base;
class Group extends Base{
    //角色列表中有对应的管理员
    public function  index(){
       //表数据
        $data=[];
        $group=model("Group")->select();
        foreach($group as $vo){
            $data[]=$vo->toArray();
        }
        //print_r($data);exit;
        //$r=[];
        foreach($data as $gid){
            $where=[
                  'gid'=>$gid['gid'],//获取Group中的所有的gid们
            ];
           $res=model("Admin")->where($where)->select();
          // $re=$res->toArray();
           foreach($res as $re){
               $admin[$gid['gid']][]= $re->toArray();
           }
            
        }
        
       return $this->fetch('',[
           'group'=>$data,
           'admin'=>$admin,
       ]); 
       
    }
    //添加角色赋权限
    public function add(){
      //传权限过去   
        
        
    return $this->fetch();     
    }
    //save处理添加和更新
    public function save(){
        
        
        
    }
    
}
